www.gusucode.com > VC++ 酒店管理系统-源码程序 > VC++ 酒店管理系统-源码程序/code/hotel2003/QQView.cpp
//Download by http://www.NewXing.com // QQView.cpp : implementation of the CQQView class // #include "stdafx.h" #include "QQ.h" #include "QQDoc.h" #include "QQView.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ////////////////////////////////////////////////////////////////////////// #include "RoomRegister.h" //登记头文件 #include "ChooseRoom.h" //选房头文件 #include "ChooseFood.h" //选食物头文件 #include "ChooseServer.h" //服务点单头文件 #include "MoneyPay.h" //支付帐单头文件 #include "Checkout.h" //结帐走人头文件 #include "GuestInfoLookup.h" //客人信息查询对话框头文件 #include "RoomInfoLookup.h" //房间信息查询对话框头文件 #include "BillInfoLookup.h" //帐单信息查询对话框头文件 #include "EmployerInfoLookup.h"//职员信息查询对话框头文件 #include "Tools.h" #include "page3.h" #include "MainFrm.h" #include "HotelInfoShow.h"//酒店概况显示对话框 #include "RoomDestine.h" //房间预定头文件 ///////////////////////////////////////////////////////////////////////////// // CQQView IMPLEMENT_DYNCREATE(CQQView, CView) BEGIN_MESSAGE_MAP(CQQView, CView) //{{AFX_MSG_MAP(CQQView) ON_COMMAND(ID_ROOM_REGISTER, OnRoomRegister) ON_COMMAND(ID_ROOM_CHOOSE, OnRoomChoose) ON_COMMAND(ID_FOOD_ORDER, OnFoodOrder) ON_COMMAND(ID_SERVER_ORDER, OnServerOrder) ON_COMMAND(ID_MONEY_CHECKOUT, OnMoneyCheckout) ON_COMMAND(ID_MONEY_STOCK, OnMoneyStock) ON_COMMAND(ID_MONEY_REPORTFORM, OnMoneyReportform) ON_COMMAND(ID_INFOLOOK_GUEST, OnInfolookGuest) ON_COMMAND(ID_INFOLOOK_BILL, OnInfolookBill) ON_COMMAND(ID_INFOLOOK_EMPLOYER, OnInfolookEmployer) ON_COMMAND(ID_INFOLOOK_FOOD, OnInfolookFood) ON_COMMAND(ID_INFOLOOK_ROOM, OnInfolookRoom) ON_COMMAND(ID_INFOLOOK_SERVER, OnInfolookServer) ON_COMMAND(ID_INFOLOOK_CONSUME, OnInfolookConsume) ON_WM_TIMER() ON_WM_ERASEBKGND() ON_COMMAND(ID_MONEY_PAY, OnMoneyPay) ON_WM_CREATE() ON_WM_LBUTTONDOWN() ON_COMMAND(ID_ROOM_DESTINE, OnRoomDestine) //}}AFX_MSG_MAP // Standard printing commands ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint) ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview) END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CQQView construction/destruction HBITMAP CQQView::m_CurScreenBitmap=NULL; BOOL CQQView::bFirstRun=TRUE; int CQQView::nImgTypeInView=-1;//普通图像类型 CPoint CQQView::pnt=CPoint(0,0); CQQView::CQQView() { // TODO: add construction code here //赋初值 strShowText=""; bFinish=false; bFirst=true; InitStructData(); } CQQView::~CQQView() { m_List.RemoveAll(); } CQQView * CQQView::GetView() {//静态成员函数 CFrameWnd * pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd); CView * pView = pFrame->GetActiveView(); if ( !pView ) return NULL; // Fail if view is of wrong kind // (this could occur with splitter windows, or additional // views on a single document if ( ! pView->IsKindOf( RUNTIME_CLASS(CQQView) ) ) return NULL; return (CQQView*) pView; } BOOL CQQView::PreCreateWindow(CREATESTRUCT& cs) { // TODO: Modify the Window class or styles here by modifying // the CREATESTRUCT cs return CView::PreCreateWindow(cs); } ///////////////////////////////////////////////////////////////////////////// // CQQView drawing void CQQView::OnDraw(CDC* pDC) { CQQDoc* pDoc = GetDocument(); ASSERT_VALID(pDoc); // TODO: add draw code for native data here LoadbgroundBitmap(pDC);//画背景 if(bFirstRun) { nImgTypeInView=0; LoadWelocmeBmp(pDC); bFirstRun=FALSE; } if(page3.bDrawTreeImage) { page3.DrawTreeImage(pDC,CPoint(50,0)); page3.bDrawTreeImage=FALSE; } if(page3.bDrawFrameImage) { page3.DrawFrameImg(pDC,CRect(page3.xStart,page3.yStart,page3.xStart+350,page3.yStart+200)); page3.bDrawFrameImage=FALSE; } } ///////////////////////////////////////////////////////////////////////////// // CQQView printing BOOL CQQView::OnPreparePrinting(CPrintInfo* pInfo) { // default preparation return DoPreparePrinting(pInfo); } void CQQView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add extra initialization before printing } void CQQView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/) { // TODO: add cleanup after printing } ///////////////////////////////////////////////////////////////////////////// // CQQView diagnostics #ifdef _DEBUG void CQQView::AssertValid() const { CView::AssertValid(); } void CQQView::Dump(CDumpContext& dc) const { CView::Dump(dc); } CQQDoc* CQQView::GetDocument() // non-debug version is inline { ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CQQDoc))); return (CQQDoc*)m_pDocument; } #endif //_DEBUG ///////////////////////////////////////////////////////////////////////////// // CQQView message handlers //加载背景图 void CQQView::LoadbgroundBitmap(CDC *pDC) {//加载视的背景图 CBitmap bitmap; bitmap.LoadBitmap(IDB_BKBMP); CDC m; m.CreateCompatibleDC(pDC);//创建一个于pDC兼容的DC m.SelectObject(&bitmap); CRect rect; this->GetClientRect(&rect); pDC->BitBlt(0,0,rect.Width(),rect.Height(),&m,0,0,SRCCOPY); m.DeleteDC(); } void CQQView::LoadWelocmeBmp(CDC* pDC) {//加载启动时的欢迎图像 CBitmap bitmap; bitmap.LoadBitmap(IDB_HOTELTEXT); CDC m; m.CreateCompatibleDC(pDC);//创建一个于pDC兼容的DC m.SelectObject(&bitmap); CRect rect; this->GetClientRect(&rect); //// long nStartX=rect.left; // long nStartY=rect.bottom-280; long nStartX=rect.left+rect.Width()/10; long nStartY=rect.top+rect.Height()/10; BITMAP m_bitmap;//定义位图结构体来保存位图信息 bitmap.GetBitmap(&m_bitmap);//得到位图结构体,记录了位图的信息 long nWidth=m_bitmap.bmWidth;//位图宽度 long nHeight=m_bitmap.bmHeight;//位图高度 pDC->BitBlt(nStartX,nStartY,nWidth,nHeight,&m,0,0,SRCCOPY); m.DeleteDC(); } void CQQView::SetBitmapText(CPoint pnt,CDC*pDC, CString strText) {//显示带有图像和文字的字符串 CBitmap bitmap; bitmap.LoadBitmap(IDB_TEXT); CDC m; m.CreateCompatibleDC(pDC); m.SelectObject(&bitmap); pDC->SetBkMode(TRANSPARENT);//设置背景模式 pDC->BitBlt(pnt.x,pnt.y,9,9,&m,0,0,SRCCOPY);//拷贝图像 pDC->TextOut(pnt.x+15,pnt.y-5,strText);//输出文本 } //################################################################### /////////////////////信息管理模块 ///////////////////////////////////////////////////////////////////// void CQQView::OnRoomRegister() { // TODO: Add your command handler code here nImgTypeInView=-1;//背景图 bFirstRun=FALSE; CGuestRegister guestreg; guestreg.DoModal();//登记对话框 } void CQQView::OnRoomChoose() { // TODO: Add your command handler code here nImgTypeInView=-1;//背景图 bFirstRun=FALSE; CChooseRoom chooseroom; chooseroom.DoModal(); } void CQQView::OnRoomDestine() {//房间预定 // TODO: Add your command handler code here bFirstRun=FALSE; CRoomDestine RoomDestine; RoomDestine.DoModal(); } void CQQView::OnFoodOrder() { // TODO: Add your command handler code here nImgTypeInView=-1;//背景图 bFirstRun=FALSE; CChooseFood choosefood; choosefood.DoModal(); } void CQQView::OnServerOrder() { // TODO: Add your command handler code here nImgTypeInView=-1;//背景图 bFirstRun=FALSE; CChooseServer chooseserver; chooseserver.DoModal(); } void CQQView::OnMoneyCheckout() {//结帐走人 // TODO: Add your command handler code here nImgTypeInView=-1;//背景图 bFirstRun=FALSE; CCheckOut checkout; checkout.DoModal(); } void CQQView::OnMoneyStock() { // TODO: Add your command handler code here nImgTypeInView=-1;//背景图 bFirstRun=FALSE; } void CQQView::OnMoneyReportform() { // TODO: Add your command handler code here nImgTypeInView=-1;//背景图 bFirstRun=FALSE; } void CQQView::OnMoneyPay() {//支付某个帐单的款项 // TODO: Add your command handler code here nImgTypeInView=-1;//背景图 bFirstRun=FALSE; CMoneyPay moneypay; moneypay.DoModal(); } ///////////////////////////////////////////////////////////////////// //################################################################### ////////////////////////////信息查询模块 ////////////////////////////////////////////////////////////////////// void CQQView::OnInfolookGuest() { // TODO: Add your command handler code her bFirstRun=FALSE; this->Invalidate(); this->UpdateData(TRUE); CDC*pDC=GetDC(); CRect rect; GetClientRect(&rect); pDC->FillSolidRect(rect,pDC->GetBkColor()); LoadbgroundBitmap(pDC);//画背景 guestinfolookup.DoModal();//模态显示对话框 ////////////////////////////////////////////////////////////////////// //////设置每行要显示的文本 CString strlineText[12];//行文本对象 strlineText[0]="客人的手牌号码(HandCode)是: "; strlineText[0]=strlineText[0]+guestinfolookup.HandCode;//设置显示文本 strlineText[1]="客人的名字是(Name): "; strlineText[1]=strlineText[1]+guestinfolookup.Name;//name strlineText[2]="客人的类型(GuestType): "; strlineText[2]=strlineText[2]+guestinfolookup.GuestType+" ";//gueatype strlineText[3]="客人性别(Sex): "; strlineText[3]=strlineText[3]+guestinfolookup.Sex;//sex strlineText[4]="客人登记时使用的证件类型(Cerificate): "; strlineText[4]=strlineText[4]+guestinfolookup.Certificate;//Certificate strlineText[5]="客人登记的证件号码是(CertifyCode): "; strlineText[5]=strlineText[5]+guestinfolookup.CertifyCode;//CertifyCode strlineText[6]="客人是否为团队成员(IsMember): "; if(guestinfolookup.IsMember){strlineText[6]=strlineText[6]+"是";} else{strlineText[6]=strlineText[6]+"否";}//ismember strlineText[7]="客人是否为团队客人的主客(IsMaster): "; if(guestinfolookup.IsMaster){strlineText[7]=strlineText[7]+"是";} else{strlineText[7]=strlineText[7]+"否";}//ismaster strlineText[8]="客人所在团队编号(GroupID): "; strlineText[8]=strlineText[8]+guestinfolookup.GroupID; strlineText[9]="客人所在团队的客人数目(GuestNum): ";CString str;str.Format("%d",guestinfolookup.GuestNum); strlineText[9]=strlineText[9]+str; strlineText[10]="团队的房间数目(RoomNum): "; strlineText[10]=strlineText[10]+guestinfolookup.RoomNum; strlineText[11]="客人所在房间的号码(RoomCode): "; strlineText[11]=strlineText[11]+guestinfolookup.RoomCode; int nWidth=rect.Width(); int nHeight=rect.Height(); CPoint potstart; potstart.x=rect.left+nWidth/10; potstart.y=rect.top+nHeight/10; if(guestinfolookup.bSuccess)//查询数据库成功则进行操作 { pDC->SetBkMode(TRANSPARENT);//设置背景模式 for(int i=0;i<12;i++) { pDC->SetBkMode(TRANSPARENT); SetBitmapText(potstart.x,potstart.y+20*i,pDC,strlineText[i]); } } ////////////////////////////////////////////////////////////////////// ClientToScreen(&rect);//将客户区域转变成屏幕坐标 m_CurScreenBitmap=::GetScreenBitmap(&rect); nImgTypeInView=0;//文字背景图 } void CQQView::OnInfolookBill() { // TODO: Add your command handler code here bFirstRun=FALSE; this->Invalidate(); this->UpdateData(TRUE); CDC*pDC=GetDC(); CRect rect; GetClientRect(&rect);//得到客户区域 pDC->FillSolidRect(rect,pDC->GetBkColor()); LoadbgroundBitmap(pDC);//画背景 CBillInfoLookup billinfolookup; billinfolookup.DoModal(); /////////////////////////////////////////////////////////////// /////////////////显示查询文本 /////////////////////////////////////////////////////////////// CString line[6]; line[0]="帐单号: "; line[0]=line[0]+billinfolookup.BillCode; line[1]="客人手牌号码: "; line[1]=line[1]+billinfolookup.HandCode; line[2]="应付总金额: ";CString str;str.Format("%d",billinfolookup.Sum); line[2]=line[2]+str; line[3]="实付金额: ";str.Format("%d",billinfolookup.Paid); line[3]=line[3]+str; line[4]="折扣率: "; line[4]=line[4]+billinfolookup.Rebate; line[5]="是/否已经付款: "; if(billinfolookup.Striked) { line[5]=line[5]+"是"; } else{ line[5]=line[5]+"否";} ////////////showtext//////////////////// int nWidth=rect.Width(); int nHeight=rect.Height(); CPoint potstart; potstart.x=rect.left+nWidth/10; potstart.y=rect.top+nHeight/10; if(billinfolookup.bSuccess)//查询数据库成功则进行操作 { pDC->SetBkMode(TRANSPARENT);//设置背景模式 for(int i=0;i<6;i++) { SetBitmapText(potstart.x,potstart.y+20*i,pDC,line[i]); } } ///////////////////////////over///////////////////////// ClientToScreen(&rect);//将客户区域转变成屏幕坐标 m_CurScreenBitmap=::GetScreenBitmap(&rect); nImgTypeInView=0;//文字背景图 } void CQQView::OnInfolookEmployer() { // TODO: Add your command handler code here bFirstRun=FALSE; this->Invalidate(); this->UpdateData(TRUE); CDC*pDC=GetDC(); CRect rect; GetClientRect(&rect); pDC->FillSolidRect(rect,pDC->GetBkColor()); LoadbgroundBitmap(pDC);//画背景 CEmployerInfoLookup employerinfolookup; employerinfolookup.DoModal(); ///////////////////show text///////////////////// CString line[3]; line[0]="员工编号: "; line[0]=line[0]+employerinfolookup.EmployerCode; line[1]="名字: "; line[1]=line[1]+employerinfolookup.Name; line[2]="所属部门: "; line[2]=line[2]+employerinfolookup.Depart; //////show text int nWidth=rect.Width(); int nHeight=rect.Height(); CPoint potstart; potstart.x=rect.left+nWidth/10; potstart.y=rect.top+nHeight/10; if(employerinfolookup.bSuccess)//查询数据库成功则进行操作 { pDC->SetBkMode(TRANSPARENT);//设置背景模式 for(int i=0;i<3;i++) { SetBitmapText(potstart.x,potstart.y+20*i,pDC,line[i]); } }//over ////////////////////////////////////////////////////////////////////////// ClientToScreen(&rect);//将客户区域转变成屏幕坐标 m_CurScreenBitmap=::GetScreenBitmap(&rect);//抓取当前客户区图像,为改变 //改变主框架大小时调用 nImgTypeInView=0;//文字背景图 } void CQQView::OnInfolookFood() { // TODO: Add your command handler code here bFirstRun=FALSE; this->UpdateData(TRUE); CDC*pDC=GetDC(); CRect rect; GetClientRect(&rect); pDC->FillSolidRect(rect,pDC->GetBkColor()); // pDC->SetBkMode(TRANSPARENT); LoadbgroundBitmap(pDC);//画背景 int nWidth=rect.Width(); int nHeight=rect.Height(); CPoint potstart; potstart.x=rect.left+nWidth/10; potstart.y=rect.top+nHeight/10; ////////////////////////////////////////////// CFoodInfoSet m_FoodInfoSet; if(!m_FoodInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE)) { MessageBox("连接数据库失败或数据库为空!","数据库错误",MB_OK); return ; } m_FoodInfoSet.MoveFirst();//to the first int i=0; while(!m_FoodInfoSet.IsEOF()) { CString foodname,foodprice,strShowText; foodname=m_FoodInfoSet.m_FoodName; foodprice.Format("%5.0f",m_FoodInfoSet.m_FoodPrice); strShowText=foodname+": "+ foodprice; pDC->SetBkMode(TRANSPARENT);//设置背景模式 SetBitmapText(potstart.x,potstart.y+20*i,pDC,strShowText); m_FoodInfoSet.MoveNext();//next i++; } m_FoodInfoSet.Close(); ClientToScreen(&rect);//将客户区域转变成屏幕坐标 m_CurScreenBitmap=::GetScreenBitmap(&rect); nImgTypeInView=0;//文字背景图 } void CQQView::OnInfolookRoom() { // TODO: Add your command handler code here bFirstRun=FALSE; this->Invalidate(); this->UpdateData(TRUE); CDC*pDC=GetDC(); CRect rect; GetClientRect(&rect); pDC->FillSolidRect(rect,pDC->GetBkColor()); LoadbgroundBitmap(pDC);//画背景 CRoomInfoLookup roominfolookup; roominfolookup.DoModal(); /////////////////////////////////////////////////////////////// CString line[7]; line[0]="房间号: "; line[0]=line[0]+roominfolookup.RoomCode; line[1]="房间类型: "; line[1]=line[1]+roominfolookup.RoomType; line[2]="房间所在楼层: "; CString str;str.Format("%d",roominfolookup.Floor); line[2]=line[2]+str; line[3]="房间电话号码: "; line[3]=line[3]+roominfolookup.Phone; line[4]="房间状态: "; line[4]=line[4]+roominfolookup.RoomStatus; line[5]="是/否团队客人成员: "; if(roominfolookup.PriceType) { line[5]=line[5]+"是"; } else{ line[5]=line[5]+"否";} line[6]="房间单位时间价格: "; str.Format("%5.00f",roominfolookup.Price); line[6]=line[6]+str; ///////showtext int nWidth=rect.Width(); int nHeight=rect.Height(); CPoint potstart; potstart.x=rect.left+nWidth/10; potstart.y=rect.top+nHeight/10; if(roominfolookup.bSuccess)//查询数据库成功则进行操作 { pDC->SetBkMode(TRANSPARENT);//设置背景模式 for(int i=0;i<7;i++) { SetBitmapText(potstart.x,potstart.y+20*i,pDC,line[i]); } }//over ClientToScreen(&rect);//将客户区域转变成屏幕坐标 m_CurScreenBitmap=::GetScreenBitmap(&rect); nImgTypeInView=0;//文字背景图 } void CQQView::OnInfolookServer() { // TODO: Add your command handler code here bFirstRun=FALSE; this->UpdateData(TRUE); CDC*pDC=GetDC(); CRect rect; GetClientRect(&rect); pDC->FillSolidRect(rect,pDC->GetBkColor()); LoadbgroundBitmap(pDC);//画背景 int nWidth=rect.Width(); int nHeight=rect.Height(); CPoint potstart; potstart.x=rect.left+nWidth/10; potstart.y=rect.top+nHeight/10; ////////////////////////////////////////////// CServerInfoSet m_ServerInfoSet; if(!m_ServerInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE)) { MessageBox("连接数据库失败或数据库为空!","数据库错误",MB_OK); return ; } m_ServerInfoSet.MoveFirst();//to the first int i=0; while(!m_ServerInfoSet.IsEOF()) { CString servername,serverprice,strShowText; servername=m_ServerInfoSet.m_ServerName; serverprice.Format("%5.0f",m_ServerInfoSet.m_ServerPrice); strShowText=servername+": "+ serverprice; pDC->SetBkMode(TRANSPARENT);//设置背景模式 SetBitmapText(potstart.x,potstart.y+20*i,pDC,strShowText); m_ServerInfoSet.MoveNext();//next i++; } m_ServerInfoSet.Close(); ClientToScreen(&rect);//将客户区域转变成屏幕坐标 m_CurScreenBitmap=::GetScreenBitmap(&rect); nImgTypeInView=0;//文字背景图 } void CQQView::OnInfolookConsume() { // TODO: Add your command handler code here bFirstRun=FALSE; } //##################################################################### void CQQView::OnTimer(UINT nIDEvent) { // TODO: Add your message handler code here and/or call default // CGuestInfoLookup guestinfolookup; // CDC* pDC=GetDC();//得到DC ////////////////////主要处理消息查询的显示 ////////////////////////////////////////////////////////////////////// /********************************************************************* 客人消息查询显示 *********************************************************************/ ///////////////////////////////////////////////////////////////////// CView::OnTimer(nIDEvent); } BOOL CQQView::OnEraseBkgnd(CDC* pDC) { // TODO: Add your message handler code here and/or call default return CView::OnEraseBkgnd(pDC); } int CQQView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here return 0; } /* * 初始化结构体数据,保存数据到结构体中供其他的地方调用 */ static LPTSTR strText[]= { "本酒店全名:华天大酒店,属于国家五星级大酒店\n是湖南地区最大的酒店", "客房部主要负责酒店的房间管理\n已经和房间有关的工作", "这是客房部的一个分枝,接待客人的职能", "管理楼层", "清洗衣物", "餐饮部主要负责客人的食物服务\n可进行:点菜,加/换、退菜的工作\n还可以订送餐等服务", "对餐厅进行管理服务", "酒吧是餐饮部的分支,为客人提供酒服务", "康乐部主要负责各种娱乐活动,添加客人在酒店的乐趣", "洗浴区为用户提供上乘的服务\n这里可以为客人提供洗澡的场所\n还可以泡温水,能让客人得到充分的享受", "休闲娱乐中心,有舞厅,歌厅,卡拉OK包厢,设施齐全,服务一流", "财务部主要负责财务的管理,包括:结帐,库存,汇总报表等", "负责酒店的各种物品的购买", "存放各种酒店的物品等", "接收钱物,为客人进行钱物结帐", NULL }; void CQQView::InitStructData() { RANGLEITEMSINFO* pInfo=new RANGLEITEMSINFO; pInfo->nIndex=0; pInfo->x1=126;pInfo->y1=8; pInfo->x2=206;pInfo->y2=45; pInfo->strContentText=strText[0]; m_List.AddTail(pInfo); pInfo=new RANGLEITEMSINFO; pInfo->nIndex=1; pInfo->x1=29;pInfo->y1=57; pInfo->x2=99;pInfo->y2=88; pInfo->strContentText=strText[1]; m_List.AddTail(pInfo); pInfo=new RANGLEITEMSINFO; pInfo->nIndex=2; pInfo->x1=106;pInfo->y1=57; pInfo->x2=170;pInfo->y2=88; pInfo->strContentText=strText[5]; m_List.AddTail(pInfo); pInfo=new RANGLEITEMSINFO; pInfo->nIndex=3; pInfo->x1=176;pInfo->y1=57; pInfo->x2=240;pInfo->y2=88; pInfo->strContentText=strText[8]; m_List.AddTail(pInfo); pInfo=new RANGLEITEMSINFO; pInfo->nIndex=4; pInfo->x1=245;pInfo->y1=57; pInfo->x2=315;pInfo->y2=88; pInfo->strContentText=strText[11]; m_List.AddTail(pInfo); pInfo=new RANGLEITEMSINFO; pInfo->nIndex=5; pInfo->x1=17;pInfo->y1=107; pInfo->x2=42;pInfo->y2=170; pInfo->strContentText=strText[2]; m_List.AddTail(pInfo); pInfo=new RANGLEITEMSINFO; pInfo->nIndex=6; pInfo->x1=47;pInfo->y1=107; pInfo->x2=77;pInfo->y2=171; pInfo->strContentText=strText[3]; m_List.AddTail(pInfo); pInfo=new RANGLEITEMSINFO; pInfo->nIndex=7; pInfo->x1=83;pInfo->y1=110; pInfo->x2=108;pInfo->y2=172; pInfo->strContentText=strText[4]; m_List.AddTail(pInfo); pInfo=new RANGLEITEMSINFO; pInfo->nIndex=8; pInfo->x1=113;pInfo->y1=112; pInfo->x2=137;pInfo->y2=173; pInfo->strContentText=strText[6]; m_List.AddTail(pInfo); pInfo=new RANGLEITEMSINFO; pInfo->nIndex=9; pInfo->x1=142;pInfo->y1=112; pInfo->x2=168;pInfo->y2=173; pInfo->strContentText=strText[7]; m_List.AddTail(pInfo); pInfo=new RANGLEITEMSINFO; pInfo->nIndex=10; pInfo->x1=172;pInfo->y1=112; pInfo->x2=201;pInfo->y2=173; pInfo->strContentText=strText[9]; m_List.AddTail(pInfo); pInfo=new RANGLEITEMSINFO; pInfo->nIndex=11; pInfo->x1=210;pInfo->y1=112; pInfo->x2=232;pInfo->y2=173; pInfo->strContentText=strText[10]; m_List.AddTail(pInfo); pInfo=new RANGLEITEMSINFO; pInfo->nIndex=12; pInfo->x1=240;pInfo->y1=112; pInfo->x2=263;pInfo->y2=174; pInfo->strContentText=strText[12]; m_List.AddTail(pInfo); pInfo=new RANGLEITEMSINFO; pInfo->nIndex=13; pInfo->x1=269;pInfo->y1=112; pInfo->x2=294;pInfo->y2=173; pInfo->strContentText=strText[13]; m_List.AddTail(pInfo); pInfo=new RANGLEITEMSINFO; pInfo->nIndex=14; pInfo->x1=300;pInfo->y1=111; pInfo->x2=327;pInfo->y2=174; pInfo->strContentText=strText[14]; m_List.AddTail(pInfo); } void CQQView::OnLButtonDown(UINT nFlags, CPoint point) { // TODO: Add your message handler code here and/or call default if(nImgTypeInView==12) { for(int i=0;i<15;i++) { CRect rect(page3.pntArray[i*2],page3.pntArray[2*i+1]); if(rect.PtInRect(point)) { //若采用CHotoelInfoShow的方法来显示信息,总算存在背景的擦除问题 //当采用动画的形式显示信息,退出对话框后,这个对话框的背景被重画 //背景被擦除,不能保持图像的一致 // [6/29/2003-9:59] // CHotelInfoShow pHotelInfo; // pHotelInfo.lpszShowText=strText[i]; // pHotelInfo.DoModal(); MessageBox(strText[i],"酒店信息介绍",MB_OK); } } } if(nImgTypeInView==13) {//当前视图区显示的是“酒店概况”图像 CRect rect; GetClientRect(&rect); pnt=point; CPoint pnt=page3.GetImgOrgPoint();//得到当前的图像原点 int n=m_List.GetCount(); for(int i=0;i<n;i++) { RANGLEITEMSINFO* pRangleInfo; POSITION pos=m_List.FindIndex(i); pRangleInfo=m_List.GetAt(pos); CRect rect(pRangleInfo->x1+pnt.x,pRangleInfo->y1+pnt.y,pRangleInfo->x2+pnt.x,pRangleInfo->y2+pnt.y); if(rect.PtInRect(point)) { //弹出消息,提示给用户关于酒店的情况 MessageBox(pRangleInfo->strContentText,"酒店情况介绍",MB_OK); // CHotelInfoShow pHotelInfo; // pHotelInfo.lpszShowText=pRangleInfo->strContentText; // pHotelInfo.pntCenter=point; // pHotelInfo.DoModal(); } } } CView::OnLButtonDown(nFlags, point); }